package com.imgdpicheck;

import com.imgdpicheck.utils.ImgCheckUtil;

import java.io.*;
import java.util.Scanner;

/**
 * @author xuehu
 * @date 2021/1/28 14:27
 */

public class FileCopyCheckDpi {

    public static void main(String[] args) {
        File file = new File("D:" + File.separator + "dpi不合格图片");
        file.mkdir();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入文件路径，输入到公司名称即可(列如 D:\\棉花厂) :");
        String nextLine = scanner.nextLine();
        checkFileOne(nextLine);
        checkFileTwo(nextLine);
        checkFileThree(nextLine);
        checkFileFour(nextLine);
        checkFileFive(nextLine);
        checkFileSix(nextLine);
        checkFileSeven(nextLine);
        checkFileEight(nextLine);
        checkFileNine(nextLine);
        checkFileTen(nextLine);
    }


    //1.检查履历材料
    public static void checkFileOne(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "1、履历材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "1、履历材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "1、履历材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //2、自传材料
    public static void checkFileTwo(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "2、自传材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "2、自传材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "2、自传材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //3、鉴定、考核、考察材料
    public static void checkFileThree(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "3、鉴定、考核、考察材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "3、鉴定、考核、考察材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "3、鉴定、考核、考察材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //    4、评定岗位技能和学历材料（包括学历、学位、培训结业成绩表等）
    public static void checkFileFour(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "4、评定岗位技能和学历材料（包括学历、学位、培训结业成绩表等）");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "4、评定岗位技能和学历材料（包括学历、学位、培训结业成绩表等）");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "4、评定岗位技能和学历材料（包括学历、学位、培训结业成绩表等）" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //5、政审材料
    public static void checkFileFive(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "5、政审材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "5、政审材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "5、政审材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //6、参加中国共产党、共青团及民主党派的材料
    public static void checkFileSix(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "6、参加中国共产党、共青团及民主党派的材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "6、参加中国共产党、共青团及民主党派的材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "6、参加中国共产党、共青团及民主党派的材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //7、奖励材料
    public static void checkFileSeven(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "7、奖励材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "7、奖励材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "7、奖励材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //8、处分材料
    public static void checkFileEight(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "8、处分材料");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "8、处分材料");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "8、处分材料" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


    //9、招用、劳动合同、调动、聘用、复员退伍、转业、工资、保险福利待遇等
    public static void checkFileNine(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "9、招用、劳动合同、调动、聘用、复员退伍、转业、工资、保险福利待遇等");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "9、招用、劳动合同、调动、聘用、复员退伍、转业、工资、保险福利待遇等");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "9、招用、劳动合同、调动、聘用、复员退伍、转业、工资、保险福利待遇等" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }

    //10、其他可供组织参考的材料（含符合条件的从事特殊工种人员辅助材料）
    public static void checkFileTen(String filePath) {
        File file = new File(filePath);
        File[] array = file.listFiles();
        for (int i = 0; i < array.length; i++) {
            if (array[i].isDirectory()) {
                // only take file name
                System.out.println("^^^^^" + array[i].getName());
                // take file path and name
                System.out.println("#####" + array[i]);
                // take file path and name
                System.out.println("*****" + array[i].getPath());

                File file1 = new File(filePath + File.separator + array[i].getName() + File.separator + "10、其他可供组织参考的材料（含符合条件的从事特殊工种人员辅助材料）");
                File[] files = file1.listFiles();
                if (files.length == 0) {
                    return;
                }
                for (int j = 0; j < files.length; j++) {
                    if (files[j].isFile()) {
                        if (ImgCheckUtil.getImageHeightDpiByFile(files[j]) < 600 || ImgCheckUtil.getImageWidthDpiByFile(files[j]) < 600) {
                            File file2 = new File("D:" + File.separator + "dpi不合格图片" + File.separator + array[i].getName() + File.separator + "10、其他可供组织参考的材料（含符合条件的从事特殊工种人员辅助材料）");
                            file2.mkdirs();
                            InputStream inputStream = null;
                            BufferedInputStream bufferedInputStream = null;
                            OutputStream outputStream = null;
                            BufferedOutputStream bufferedOutputStream = null;
                            try {
                                inputStream = new FileInputStream(filePath + File.separator + array[i].getName() + File.separator + "10、其他可供组织参考的材料（含符合条件的从事特殊工种人员辅助材料）" + File.separator + files[j].getName());
                                bufferedInputStream = new BufferedInputStream(inputStream);
                                byte[] bytes = new byte[1024];
                                File filess = new File(file2 + File.separator + "不合格图片" + System.currentTimeMillis() + ".jpg");
                                outputStream = new FileOutputStream(filess);
                                bufferedOutputStream = new BufferedOutputStream(outputStream);
                                int len = 0;
                                while ((len = bufferedInputStream.read(bytes)) != -1) {
                                    bufferedOutputStream.write(bytes, 0, len);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            } finally {
                                if (bufferedInputStream != null) {
                                    try {
                                        bufferedInputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }
                    }
                }

            }
        }
    }


}
